package demo01;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ConstructorDemo {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Constructor<Student> constructor = Student.class.getConstructor(String.class);
        Student student = constructor.newInstance("张三");
        System.out.println(student);
        System.out.println("==================");
        Constructor<Student> constructor1 = Student.class.getConstructor(String.class, Integer.class);
        Student student1 = constructor1.newInstance("张三", 18);
        System.out.println(student1);
        System.out.println("==================");
    }
}
